<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="javascript" type="text/javascript" src="datetimepicker.js">
</script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript">
function validateMovie()
{
var flag = true;
var mname=document.forms["createMovieForm"]["movieName"].value;
var mbanner=document.forms["createMovieForm"]["movieBanner"].value;
var copy=document.forms["createMovieForm"]["copies"].value;
var rent=document.forms["createMovieForm"]["rent"].value;
var date=document.forms["createMovieForm"]["dateText"].value;
var numericExpression = /^[0-9]+$/;
document.all("mname").innerHTML  = "";
document.all("bname").innerHTML  = "";
document.all("copy").innerHTML  = "";
document.all("rentu").innerHTML  = "";
document.all("cal").innerHTML  = "";
	if (mname==null || mname=="")
	{
		document.all("mname").innerHTML  = "Movie Name must be filled out";
		flag = false;
	}
	if (mbanner==null || mbanner=="")
	{
		document.all("bname").innerHTML  = "Banner Name must be filled out";
		flag = false;
	}
	if (copy==null || copy=="" || !copy.match(numericExpression))
	{

		document.all("copy").innerHTML  = "Correct No. of copies must be filled out";
		flag = false;
	}
	if (rent==null || rent=="" || !rent.match(numericExpression))
	{
		document.all("rentu").innerHTML  = "Correct Rent must be filled out";
		flag = false;
	}
	if (date==null || date=="")
	{
		document.all("cal").innerHTML  = "Release date must be filled out";
		flag = false;
	}
	return flag;
}
</script>
</head>
<body>
<%@ include file="header.jsp" %>
<form id="newMovieForm" name="createMovieForm" method="POST" action="CreateMovieServlet" onsubmit="return validateMovie();">

<div class="inputColumn" id="createAccount"
	style="text-align: center; border: thin; margin: auto;">
<table cellpadding="2" cellspacing="1" border="0" width="100%">
	<tr>
	<th colspan="2">
	<font size="2" color="red"><sup>*</sup> Required Fields</font></th>
	</tr>
	<tr>
	<td colspan="2">
	<% String serverException = (String)request.getAttribute("ServerMessage");
					if(serverException != null){
				%><br> <label style="size: 32; color: red"><%=serverException%></label> <%} %>
	</td>
	</tr>
	<tr>
	<td>
		<table  cellpadding="2" cellspacing="1" border="1" width="65%" style="background-color: rgb(254,252,180);">
			
			<tr>
			<td valign="top" align="left">
			<b>Movie Name<sup style="color: red">*</sup></b> </td><td valign="top" align="left">
			<input id="movieName" type="text" name="movieName" size="35" maxlength="20" style="background-color:#eeeeee;"> 
			<br> <label id="mname"  style="size: 32; color: red"></label> 
			 </td>
			 </tr>
			 <tr>
			<td valign="top" align="left">
			<b>Movie Banner<sup style="color: red">*</sup></b></td><td valign="top" align="left">
			<input type="text" name="movieBanner" id="movieBanner" size="35" maxlength="20" style="background-color:#eeeeee;">
			<br> <label id="bname"  style="size: 32; color: red"></label> 
			</td>
			</tr>
			<tr>
				<td valign="top" align="left">
				<b>Category<sup style="color: red">*</sup></b></td><td valign="top" align="left">
				<select name="category" size="1" >
				<option value="1" selected >Action</option>
				<option value="2" >Comedy</option>
				<option value="3" >Family</option>
				<option value="4" >History</option>
				<option value="5">Mystry</option>
				<option value="6">Sci-Fi</option>
				<option value="7">Adventure</option>
				<option value="8">Crime</option>
				<option value="9">Horror</option>
				<option value="10">Romance</option>
				</select>
				</td>
			</tr>
				
			<tr>
				<td valign="top" align="left">
				<b>No of Copies<sup style="color: red">*</sup></b></td><td valign="top" align="left">
				<input type="text" name="copies" size="5" maxlength="2" style="background-color:#eeeeee;">
				<br><label id="copy" style="size: 32; color: red"></label> 
				</td>
			</tr>
			<tr>
				<td valign="top" align="left">
				<b>Rent<sup style="color: red">*</sup></b></td><td valign="top" align="left">
				<input type="text" name="rent" size="5" maxlength="2" style="background-color:#eeeeee;">
				<br><label id="rentu" style="size: 32; color: red"></label> 
				</td>
			</tr>
			<tr>
			  <td valign="top" align="left">
				<b>Release Date<sup style="color: red">*</sup></b></td><td valign="top" align="left">
				<input id="dateText" name="dateText" type="text" readonly="readonly" size="25" style="background-color:#eeeeee">
						<a href="javascript:NewCal('dateText','DDMMYYYY')">
						<img src="Images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>
				<br><label id="cal" style="size: 32; color: red"></label> 
				
				</td>
				
			</tr>
	</table>
	<tr>
		<td align="center" colspan="2"><input type="submit"
			value="Create Movie"> </td>
	</tr>
</table>
</div>
</form>
</body>
</html>